package com.briup.product_source.service.impl;

import com.briup.product_source.dao.ManagerDiseaseMapper;
import com.briup.product_source.dao.ext.DiseaseRecordExtMapper;
import com.briup.product_source.exception.ServiceException;
import com.briup.product_source.pojo.ManagerDisease;
import com.briup.product_source.pojo.ext.DiseaseRecordExt;
import com.briup.product_source.service.DiseaseRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DiseaseRecordServiceImpl implements DiseaseRecordService {
    @Autowired
    private ManagerDiseaseMapper diseaseMapper;
    @Autowired
    private DiseaseRecordExtMapper diseaseExtMapper;
    @Override
    public List<ManagerDisease> findAllDiseases() {
        return diseaseMapper.selectAll();
    }

    @Override
    public PageInfo<DiseaseRecordExt> findByPage(Integer pageNum, Integer pageSize, String drStatus, Integer drDId) throws ServiceException {
        //1.开启分页查询
        PageHelper.startPage(pageNum, pageSize);
        //2.条件查询
        List<DiseaseRecordExt> diseaseRecordExt = diseaseExtMapper.selectDiseasedAnimal(drStatus, drDId);
        //3.封装分页对象并返回
        PageInfo<DiseaseRecordExt> pageInfo = new PageInfo(diseaseRecordExt);
        return pageInfo;
    }

}
